<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title></title>
</head>

<body>
</body>
<script>
    var event = new CustomEvent('build');

    document.addEventListener('build', function (e) { 
        alert('hahah')
    }, false);

    document.dispatchEvent(event);
</script>

</html>